<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .yellow{
            height: 200px;
            width: 200px;
            background-color: yellow;
        }

        .red{
            height: 300px;
            width: 300px;
            background-color: red;
        }
        
    </style>
</head>
<body>
    <div>点我变</div>
    <script>
        var div=document.querySelector('div')
        div.onclick=function(){
        
        this.className='red'

        }

    
    </script>
</body>
</html>